// ----------------------------------------------------------------------------
// Copyright 2006, Martin D. Flynn
// All rights reserved
// ----------------------------------------------------------------------------
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ----------------------------------------------------------------------------
// Description:
//  This class manages the transport layer for the OpenDMTP protocol.
// ----------------------------------------------------------------------------
// Change History:
//  2006/03/31  Martin D. Flynn
//      Initial release
// ----------------------------------------------------------------------------
package org.traffometer.opendmtp.protocol;

/**
 * The Transport interface.
 * 
 * @author Martin D. Flynn
 * @author Elayne Man
 * 
 */
public interface Transport {

  /**
   * Determines if the transport is open.
   * 
   * @return True if transport is open
   */
  public boolean isOpen();

  /**
   * Opens the transport medium.
   * 
   * @param xportType The transport type
   * @return If successful
   */
  public boolean open(int xportType);

  /**
   * Closes the transport medium.
   * 
   * @param sendUDP True if sending UDP packets
   * @return If successful
   */
  public boolean close(boolean sendUDP);

  /**
   * Reads packets.
   * 
   * @return the packets read
   */
  public byte[] readPacket();

  /**
   * Writes to the packets.
   * 
   * @param b Information to be written
   * @return the packet length
   */
  public int writePacket(byte b[]);
}
